﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IGGWindowApp.Controls;
using IGGCore;

namespace IGGWindowApp.Panels
{
    public partial class PanelTwitter : UserControl
    {
        // EVENTS
        public delegate void ItemSelectedHandler(string item);
        public event ItemSelectedHandler ItemSelected;
        public LinkClickedEventHandler URLClicked;

        public PanelTwitter()
        {
            InitializeComponent();
            //panelTitle.Initialize(new string[] { "Twitter", "Trans", "Game", "Stars", "Logs" });
            //panelTitle.ItemSelected += new PanelTitleLeft.ItemSelectedHandler(panelTitle_ItemSelected);
        }

        private void panelTitle_ItemSelected(string item)
        {
            ItemSelected(item);
        }

        public void SetData(Tweet[] tweets)
        {
            txtTw5.Text = tweets[4].Text;
            txtTw5.Visible = true;
            lblAuthor5.Text = tweets[4].Author;
            lblAuthor5.Visible = true;

            txtTw4.Text = tweets[3].Text;
            txtTw4.Visible = true;
            lblAuthor4.Text = tweets[3].Author;
            lblAuthor4.Visible = true;

            txtTw3.Text = tweets[2].Text;
            txtTw3.Visible = true;
            lblAuthor3.Text = tweets[2].Author;
            lblAuthor3.Visible = true;

            txtTw2.Text = tweets[1].Text;
            txtTw2.Visible = true;
            lblAuthor2.Text = tweets[1].Author;
            lblAuthor2.Visible = true;

            txtTw1.Text = tweets[0].Text;
            txtTw1.Visible = true;
            lblAuthor1.Text = tweets[0].Author;
            lblAuthor1.Visible = true;
        }

        private void LinkClicked(object sender, LinkClickedEventArgs e)
        {
            URLClicked(this, e);
        }

        private void ContentsResized(object sender, ContentsResizedEventArgs e)
        {
            ((RichTextBox)sender).Height = e.NewRectangle.Height + 9;
            ((RichTextBox)sender).Refresh(); 
        }
    }
}
